// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Nodes.Json;

public sealed partial class NodesInfoMetricConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric>
{
	private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("_all");
	private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("_none");
	private static readonly System.Text.Json.JsonEncodedText MemberAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations");
	private static readonly System.Text.Json.JsonEncodedText MemberHttp = System.Text.Json.JsonEncodedText.Encode("http");
	private static readonly System.Text.Json.JsonEncodedText MemberIndices = System.Text.Json.JsonEncodedText.Encode("indices");
	private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest");
	private static readonly System.Text.Json.JsonEncodedText MemberJvm = System.Text.Json.JsonEncodedText.Encode("jvm");
	private static readonly System.Text.Json.JsonEncodedText MemberOs = System.Text.Json.JsonEncodedText.Encode("os");
	private static readonly System.Text.Json.JsonEncodedText MemberPlugins = System.Text.Json.JsonEncodedText.Encode("plugins");
	private static readonly System.Text.Json.JsonEncodedText MemberProcess = System.Text.Json.JsonEncodedText.Encode("process");
	private static readonly System.Text.Json.JsonEncodedText MemberRemoteClusterServer = System.Text.Json.JsonEncodedText.Encode("remote_cluster_server");
	private static readonly System.Text.Json.JsonEncodedText MemberSettings = System.Text.Json.JsonEncodedText.Encode("settings");
	private static readonly System.Text.Json.JsonEncodedText MemberThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool");
	private static readonly System.Text.Json.JsonEncodedText MemberTransport = System.Text.Json.JsonEncodedText.Encode("transport");

	public override Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
	{
		if (reader.ValueTextEquals(MemberAll))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.All;
		}

		if (reader.ValueTextEquals(MemberNone))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.None;
		}

		if (reader.ValueTextEquals(MemberAggregations))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Aggregations;
		}

		if (reader.ValueTextEquals(MemberHttp))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Http;
		}

		if (reader.ValueTextEquals(MemberIndices))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Indices;
		}

		if (reader.ValueTextEquals(MemberIngest))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Ingest;
		}

		if (reader.ValueTextEquals(MemberJvm))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Jvm;
		}

		if (reader.ValueTextEquals(MemberOs))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Os;
		}

		if (reader.ValueTextEquals(MemberPlugins))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Plugins;
		}

		if (reader.ValueTextEquals(MemberProcess))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Process;
		}

		if (reader.ValueTextEquals(MemberRemoteClusterServer))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.RemoteClusterServer;
		}

		if (reader.ValueTextEquals(MemberSettings))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Settings;
		}

		if (reader.ValueTextEquals(MemberThreadPool))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.ThreadPool;
		}

		if (reader.ValueTextEquals(MemberTransport))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Transport;
		}

		var value = reader.GetString()!;
		if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.All;
		}

		if (string.Equals(value, MemberNone.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.None;
		}

		if (string.Equals(value, MemberAggregations.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Aggregations;
		}

		if (string.Equals(value, MemberHttp.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Http;
		}

		if (string.Equals(value, MemberIndices.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Indices;
		}

		if (string.Equals(value, MemberIngest.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Ingest;
		}

		if (string.Equals(value, MemberJvm.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Jvm;
		}

		if (string.Equals(value, MemberOs.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Os;
		}

		if (string.Equals(value, MemberPlugins.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Plugins;
		}

		if (string.Equals(value, MemberProcess.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Process;
		}

		if (string.Equals(value, MemberRemoteClusterServer.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.RemoteClusterServer;
		}

		if (string.Equals(value, MemberSettings.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Settings;
		}

		if (string.Equals(value, MemberThreadPool.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.ThreadPool;
		}

		if (string.Equals(value, MemberTransport.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Transport;
		}

		throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric)}'.");
	}

	public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric value, System.Text.Json.JsonSerializerOptions options)
	{
		switch (value)
		{
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.All:
				writer.WriteStringValue(MemberAll);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.None:
				writer.WriteStringValue(MemberNone);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Aggregations:
				writer.WriteStringValue(MemberAggregations);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Http:
				writer.WriteStringValue(MemberHttp);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Indices:
				writer.WriteStringValue(MemberIndices);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Ingest:
				writer.WriteStringValue(MemberIngest);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Jvm:
				writer.WriteStringValue(MemberJvm);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Os:
				writer.WriteStringValue(MemberOs);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Plugins:
				writer.WriteStringValue(MemberPlugins);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Process:
				writer.WriteStringValue(MemberProcess);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.RemoteClusterServer:
				writer.WriteStringValue(MemberRemoteClusterServer);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Settings:
				writer.WriteStringValue(MemberSettings);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.ThreadPool:
				writer.WriteStringValue(MemberThreadPool);
				break;
			case Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric.Transport:
				writer.WriteStringValue(MemberTransport);
				break;
			default:
				throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric)}'.");
		}
	}

	public override Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
	{
		return Read(ref reader, typeToConvert, options);
	}

	public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Nodes.NodesInfoMetric value, System.Text.Json.JsonSerializerOptions options)
	{
		Write(writer, value, options);
	}
}